﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using WebService.DataAccess;using WebService.BusinessEntities;

namespace WebService.DataAccess
{
    /// <summary>
    /// Construct a Wallet object from a datareader.
    /// </summary>
    internal class GET_WALLET_PROCFactory : IDomainObjectFactory<Wallet>
    {
        public Wallet Construct(IDataReader reader)
        {
            Wallet wallet = new Wallet();

            int game_idIndex = reader.GetOrdinal("game_id");
            if (!reader.IsDBNull(game_idIndex))
            {
                wallet.game_id = reader.GetInt32(game_idIndex);

            }

            int user_idIndex = reader.GetOrdinal("user_id");
            if (!reader.IsDBNull(user_idIndex))
            {
                wallet.user_id = reader.GetInt32(user_idIndex);

            }

            int debitIndex = reader.GetOrdinal("debit");
            if (!reader.IsDBNull(debitIndex))
            {
                wallet.debit = reader.GetInt32(debitIndex);

            }

            int creditIndex = reader.GetOrdinal("credit");
            if (!reader.IsDBNull(creditIndex))
            {
                wallet.credit = reader.GetInt32(creditIndex);

            }


            return wallet;
        }
    }
}

